package com.micro.modual.controller;

import com.micro.core.resp.RespJsonData;
import com.micro.modual.model.dto.permission.FrontUserInfoDTO;
import com.micro.modual.model.tree.MenuTreeDTO;
import com.micro.modual.service.PermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <h1>权限相关认证</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020/3/2
 */
@Api(tags = "权限相关认证")
@RestController
@RequestMapping(value = "/permission")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    /**
     * <h2>获取用户信息</h2>
     * @return {@link FrontUserInfoDTO} 前端用户信息返回对象
     */
    @ApiOperation(value = "获取用户信息",notes = "获取用户信息")
    @GetMapping(value = "/getUserInfo")
    public RespJsonData<FrontUserInfoDTO> getUserInfo(){
        return permissionService.getUserInfo();
    }

    /**
     * <h2>获取该用户拥有的菜单权限</h2>
     * @return {@link MenuTreeDTO} s 菜单树
     */
    @ApiOperation(value = "获取用户拥有的菜单权限",notes = "获取用户拥有的菜单权限")
    @GetMapping(value = "/getUserMenus")
    public RespJsonData<List<MenuTreeDTO>> getUserMenus(){
        return permissionService.getUserMenus();
    }
}
